//
//  YCFileStorageManager.h
//  Pods
//
//  Created by Apple on 2022/11/12.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

#define kFileStorageManager [YCFileStorageManager manager]

@interface YCFileStorageManager : NSObject

@property (nonatomic, copy) NSString *fileStorageKey;

+ (instancetype)manager;

// 同步接口，文件是否存在
- (BOOL)fileExists:(NSString *)name;

// 同步写文件
- (void)writeFile:(NSData *)data name:(NSString *)name;

// 写入文件，文件名是 name，当异步写入完成时，会回调 completion。result 返回是否成功
- (void)writeFile:(NSData *)data name:(NSString *)name completion:(nullable void(^)(BOOL result))completion;

// 异步读取文件，文件名是 name，完成时会将文件数据在 completion 返回
- (void)readFile:(NSString *)name completion:(nullable void(^)(NSData *data))completion;

// 同步读文件
- (NSData *)readFile:(NSString *)name;

// 同步删除文件
- (void)removeFile:(NSString *)name;

// 异步删除文件
- (void)removeFile:(NSString *)name completion:(nullable void(^)(BOOL result))completion;

// 异步删除所有文件
- (void)removeAllFilesWithCompletion:(nullable void(^)(BOOL result))completion;

@end

NS_ASSUME_NONNULL_END
